﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AssemblyInfoEditor.VersionManagement
{
    public static class TimeSpanHelper
    {
        public static DateTime GetDateSpanLength(DateTime date1, DateTime date2)
        {
            return new DateTime(date1.Subtract(date2).Ticks);

            // ** Note on this Method **
            // The original version of this method is part of the Build Version Increment add-in
            // found at http://autobuildversion.codeplex.com/.
            //
            // Here is the original method:
            //
            // public static DateSpan GetDateDifference(DateTime date, DateTime dateToCompare)
            // {
            //     int totalMonths = ((date.Year - dateToCompare.Year) * 12) + date.Month - dateToCompare.Month;
            // 
            //     TimeSpan diff1 = date.Subtract(dateToCompare);
            // 
            //     DateTime finaldt = new DateTime(diff1.Ticks);
            // 
            //     DateSpan ds = new DateSpan();
            //     ds.Years = finaldt.Year;
            //     ds.Months = finaldt.Month;
            //     ds.Days = finaldt.Day;
            //
            //     return ds;
            // }
            //
            // I'm not sure what function 'totalMonths' serves, it must have been left over from
            // an older version of the code.
            // For my version of the method, I essentially just condensed the rest of the code
            // into a single line and scrapped the custom class he created for simplicity's sake.
        }
    }
}
